package com.cust.zy.newtask.tools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by zhuangyuan on 4/16/2017.
 * 邮箱：zhuangyuan.k@qq.com
 */

public class OtherTools {

    public static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    public static int getDifferenceBetweenGenerateAndCur(String generateTimeString) throws ParseException {
        Date generateTime = simpleDateFormat.parse(generateTimeString);
        Date curTime = simpleDateFormat.parse(simpleDateFormat.format(new Date()));
        Calendar cal = Calendar.getInstance();
        cal.setTime(generateTime);
        long generate = cal.getTimeInMillis();
        long time1 = cal.getTimeInMillis();
        cal.setTime(curTime);
        long cur = cal.getTimeInMillis();
        long between_days=(cur-generate)/(1000*3600*24);
        return Integer.parseInt(String.valueOf(between_days));
    }
}
